//
//  ACAnchorMemberListCell.m
//  ACLiteAVUISDK
//
//  Created by 冯琰琰 on 2021/4/1.
//

#import "ACAnchorMemberListCell.h"

@interface ACAnchorMemberListCell ()

@property (weak, nonatomic) IBOutlet UIImageView *headerIcon;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@end

@implementation ACAnchorMemberListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.headerIcon.layer.masksToBounds = YES;
    self.headerIcon.layer.cornerRadius = 19;
    
    self.inviteAnchorBtn.layer.masksToBounds = YES;
    self.inviteAnchorBtn.layer.cornerRadius = 14;
    
    self.kickOutBtn.layer.masksToBounds = YES;
    self.kickOutBtn.layer.cornerRadius = 14;
    self.kickOutBtn.layer.borderColor = UIColorFromRGB(0xE2E1E0).CGColor;
    self.kickOutBtn.layer.borderWidth = 1;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)kickOutBtnClick:(id)sender {
    if (self.clickActionHandler) {
        self.clickActionHandler(1);
    }
}

- (IBAction)inviteAnchorBtnClick:(id)sender {
    if (self.clickActionHandler) {
        self.clickActionHandler(2);
    }
}

-(void)setUserInfo:(TRTCLiveUserInfo *)userInfo{
    _userInfo = userInfo;
    if ([_userInfo.userId isEqualToString:[[ACUserProfileManager shareInstance] getUserModel].user_id]) {
        [self.kickOutBtn setHidden:YES];
        [self.inviteAnchorBtn setHidden:YES];
    }else{
        [self.kickOutBtn setHidden:NO];
        [self.inviteAnchorBtn setHidden:NO];
    }
    NSString *headIconStr = _userInfo.avatarURL;
    if ((![headIconStr startsWith:@"http://"] && ![headIconStr startsWith:@"https://"]) && headIconStr != nil) {
        headIconStr = [@"http://" stringByAppendingString:headIconStr];
    }
    [self.headerIcon sd_setImageWithURL:[NSURL URLWithString:headIconStr]];
    self.nameLabel.text = _userInfo.userName;
}

@end
